﻿using Hotel.BLL;
using Hotel.DAL;
using Hotel.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Hotel.Server.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ShopController : ControllerBase
    {
        public ShopController(ShopBLL shopBLL)
        {
            ShopBLL = shopBLL;
        }

        public ShopBLL ShopBLL { get; }





        /// <summary>
        /// 添加门店
        /// </summary>
        /// <param name="shopModel"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ShopAdd(ShopModel shopModel)
        {
            int res = ShopBLL.ShopAdd(shopModel);
            return Ok(res);


        }



        /// <summary>
        /// 门店列表
        /// </summary>
        /// <param name="count">总条数</param>
        /// <param name="page">总页码</param>
        /// <param name="rightName">名称</param>
        /// <param name="createtiem">时间</param>
        /// <param name="index">页码</param>
        /// <param name="size">页容量</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetShopList( string? shopName = "", int index = 1, int size = 2)
        {
            int count = 0;
            int page = 0;
            List<ShopModel> list = ShopBLL.GetShopList(out count, out page, shopName, index, size);
            return Ok(new { list = list, count = count, page = page });
        }



        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult DelAllShopItem(string ids)
        {
            var res = ShopBLL.DelAllShopItem(ids);
           return Ok(res);
        }




        /// <summary>
        /// 批量上下架
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        [HttpPut]
        public IActionResult UpOrDownAllShowItem(string ids, int state)
        {
            var res = ShopBLL.UpOrDownAllShowItem(ids, state);
            return Ok(res);

        }





    }
}
